<?php
/**
 * @Author:      lyt
 * @DateTime:    2016-02-17 15:32:52
 * @Description: 用于门店仓库的model
 */
class MainDateBase extends Eloquent
{
    protected $table = "maintenance_datebase";

    /**
     * @Author:      lyt
     * @DateTime:    2016-02-17 15:35:59
     * @Description: Description
     */
    public static function getDateByShop($shop_id){
    	return MainDateBase::where("shop_id",$shop_id)->where("status",1)->get();
    }


    public static function initDateShop($shop_id){
    	return DB::transaction(function () use ($shop_id) {
    		$mb=new  MainDateBase;
    		$mb->shop_id=$shop_id;
    		$mb->name="配件库";
    		$mb->type=0;
    		$mb->status=1;
    		$mb->save();

    		$mb1=new MainDateBase;
    		$mb1->shop_id=$shop_id;
    		$mb1->name="辅料库";
    		$mb1->type=1;
    		$mb1->status=1;
    		$mb1->save();            
            return true;
        });
    }

}
